package com.whz.http.web;

import com.whz.generic.json.JacksonUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

/**
 * @author whz
 */
@Configuration
public class GenericHttpMessageConvertConfiguration {
    @Bean
    @ConditionalOnProperty(name = "generic.jackson.enable", havingValue = "true")
    public HttpMessageConverters jacksonHttpMessageConverters() {
        return new HttpMessageConverters(
                new MappingJackson2HttpMessageConverter(JacksonUtils.createDefaultObjectMapper()));
    }
}